<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
	class database_model extends CI_Model{
		public function __construct(){
			parent::__construct();
		}
        
		public function GetWhere($tbname, $data, $limit = null, $offset = null){
			$rs = $this->db->get_where($tbname, $data, $limit, $offset);
			return $rs;
		}

		public function Get($tbname){
            $rs = $this->db->get($tbname);
            return $rs;
        }

        public function Count($tbname, $where= null){
            $rs = $this->db->get_where($tbname, $where);
            return $rs->num_rows();
        }

        public function Insert($tbname, $data){
            $this->db->insert($tbname, $data);
            return $this->db->insert_id();
        }

        public function Update($tbname, $data, $where){
            $this->db->where($where);
            $rs = $this->db->update($tbname, $data);
            return $rs;
        }

        public function Delete($tbname, $where){
            $rs = $this->db->delete($tbname, $where);
            return $rs;
        }
	}
?>